var mongoose = require("mongoose"); //安装mongoose驱动

//供应商录入
const up = async data => await mongoose.model("supplier").create(data);

//增加订单
const upS = async data => await mongoose.model("supplyOrder").create(data);

//查找商录入
const getSupplier = async () => await mongoose.model("supplier").find();

//订单
const getOrder = async () => await mongoose.model("supplyOrder").find();

//删除供应商
const delSupplier = async _id => await mongoose.model("supplier").remove(_id);

//删除订单
const delOrder = async _id => await mongoose.model("supplyOrder").remove(_id);

//修改供应商
const upSupplier = async (_id, par) =>
  await mongoose.model("supplier").update({ _id }, par);

//修改订单
const upOrder = async (_id, par) =>
  await mongoose.model("supplyOrder").update({ _id }, par);

module.exports = {
  up,
  getSupplier,
  delSupplier,
  upSupplier,
  upS,
  getOrder,
  delOrder,
  upOrder
};
